$def with (view, pickup=None)
<div style="float:right;text-align:right;"><a href="map.html">Plan-Konfiguration</a><br><a href="coupon.html">Gutschein-Verwaltung</a><br><a href="newsletter.html">Rundschreiben</a></div>
<h1><a href="../../members.html">Chorverwaltung</a>: Karten</h1>
<p>$view.tag.description</p>
<h2>Übersicht über alle Karten</h2>
<table id="list" cellspacing="0" cellpadding="0" border="0">
  <tr><td></td><th>Anzahl</th><th>Wert</th><th>Gutscheine</th><th>Einnahmen</th></tr>
  <tr><th>verkauft</th><td align="right"><a href="map.pdf?booked=1">$view.booked_sum.count</a></td><td align="right">€$(view.booked_sum.sum or 0)</td><td align="right">€$(view.coupon_used.sum or 0)</td><td align="right">€${(view.booked_sum.sum or 0)-(view.coupon_used.sum or 0)}</td></tr>
  <tr><th>frei</th><td align="right"><a href="map.pdf?available=1">$view.available.count</a></td><td align="right">€$(view.available.sum or 0)</td><td align="right">€$(view.coupon_available.sum or 0)</td><td align="right">€${(view.available.sum or 0)-(view.coupon_available.sum or 0)}</td></tr>
  <tr><th>Summe</th><td align="right"><a href="map.pdf">$view.total.count</a></td><td align="right">€$(view.total.sum or 0)</td><td align="right">€$((view.coupon_used.sum or 0)+(view.coupon_available.sum or 0))</td><td align="right">€${(view.total.sum or 0)-(view.coupon_used.sum or 0)-(view.coupon_available.sum or 0)}</td></tr>
</table>
<hr>
<div style="float:right;"><a href="new.html">Neue Kartenzuteilung</a></div>
<h2>Nicht online gekaufte Karten</h2>
<table id="list" cellspacing="0" cellpadding="0" border="0">
  <tr><th>Name</th><th>Anzahl</th><th>Wert</th><th>Gutscheine</th><th>Einnahmen</th><th>Aktion</th></tr>
$for sold, count, s, coupons in view.booked:
    $if not sold.online:
        <tr onmouseover="style.backgroundColor='#ccc';" onmouseout="style.backgroundColor='#fff';">
          <td>$sold.name</td>
          <td align="right">
            $if count:
                <a href="map.pdf?sold=$sold.id">$count</a>
            $else:
                0
          </td>
          <td align="right">€$(s or 0)</td>
          <td align="right">€${coupons or 0}</td>
          <td align="right">€${(s or 0)-(coupons or 0)}</td>
          <td>
            <a href="sold/$sold.id/edit.html">Bearbeiten</a>,
            <a href="sold/$sold.id/delete.html">Löschen</a>\
          </td>
        </tr>
  <tr>
    <td><b>Summe</b></td>
    <td align="right"><b><a href="map.pdf?booked_online=1"></a>$sum([(count or 0) for sold, count, s, coupons in view.booked if not sold.online])</b></td>
    <td align="right"><b>€$sum([(s or 0) for sold, count, s, coupons in view.booked if not sold.online])</b></td>
    <td align="right"><b>€$sum([(coupons or 0) for sold, count, s, coupons in view.booked if not sold.online])</b></td>
    <td align="right"><b>€$sum([((s or 0)-(coupons or 0)) for sold, count, s, coupons in view.booked if not sold.online])</b></td>
    <td>&nbsp;</td>
  </tr>
</table>
<hr>
<h2>Online gekaufte Karten</h2>
<form method="POST" action="index.html">
  <p>
    Online-Verkauf ist
$if view.instance.onsale == view.tag:
    <b>aktiv</b>, <input type="submit" name="action_deactivate" value="deaktivieren">.
    $if view.instance.sale_temporarily_closed:
        Der Verkauf ist vorübergehend geschlossen wegen Vorverkauf im Chor,
        <input type="submit" name="action_open" value="Verkauf wieder öffnen">.
    $else:
        Der Verkauf ist geöffnet,
        <input type="submit" name="action_close" value="Verkauf vorübergehend schließen"> (wegen Vorverkauf bei der Chorprobe).
$else:
    <b>nicht aktiv</b>, <input type="submit" name="action_activate" value="aktivieren">.
  </p>
</form>
<table id="list" cellspacing="0" cellpadding="0" border="0">
  <tr><th>Name</th><th>Reservierung</th><th>Bezahlung</th><th>Anzahl</th><th>Wert</th><th>Gutscheine</th><th>Einnahmen</th><th>Aktion</th></tr>
$for sold, count, s, coupons in view.booked:
    $if sold.online:
        <tr onmouseover="style.backgroundColor='#ccc';" onmouseout="style.backgroundColor='#fff';">
          <td>$sold.name</td>
          <td>
            $sold.created.strftime('%d.%m.%Y'),
            $sold.id/$sold.bankcode
          </td>
          <td>
            $if sold.payed:
                $sold.payed.strftime('%d.%m.%Y'),
                $sold.id/$sold.pickupcode
            $else:
                <a href="sold/$sold.id/pay.html">Zahlungseingang&nbsp;buchen</a>,
                <a href="sold/$sold.id/remind.html">Erinnerung&nbsp;verschicken</a>
          </td>
          <td align="right"><a href="map.pdf?sold=$sold.id">$count</a></td>
          <td align="right">€$s</td>
          <td align="right">€${coupons or 0}</td>
          <td align="right">€${s-(coupons or 0)}</td>
          <td>
            <a href="sold/$sold.id/pickup.html">Abholschein</a>,
            <a href="sold/$sold.id/edit.html">Bearbeiten</a>,
            <a href="sold/$sold.id/delete.html">Löschen</a>
          </td>
        </tr>
  <tr>
    <td colspan="3"><b>Summe</b></td>
    <td align="right"><b>$sum([(count or 0) for sold, count, s, coupons in view.booked if sold.online])</b></td>
    <td align="right"><b>€$sum([(s or 0) for sold, count, s, coupons in view.booked if sold.online])</b></td>
    <td align="right"><b>€$sum([(coupons or 0) for sold, count, s, coupons in view.booked if sold.online])</b></td>
    <td align="right"><b>€$sum([((s or 0)-(coupons or 0)) for sold, count, s, coupons in view.booked if sold.online])</b></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="3">davon bereits gebucht</td>
    <td align="right">$sum([(count or 0) for sold, count, s, coupons in view.booked if sold.online and sold.payed])</td>
    <td align="right">€$sum([(s or 0) for sold, count, s, coupons in view.booked if sold.online and sold.payed])</td>
    <td align="right">€$sum([(coupons or 0) for sold, count, s, coupons in view.booked if sold.online and sold.payed])</td>
    <td align="right">€$sum([((s or 0)-(coupons or 0)) for sold, count, s, coupons in view.booked if sold.online and sold.payed])</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="3">und noch nicht gebucht</td>
    <td align="right">$sum([(count or 0) for sold, count, s, coupons in view.booked if sold.online and not sold.payed])</td>
    <td align="right">€$sum([(s or 0) for sold, count, s, coupons in view.booked if sold.online and not sold.payed])</td>
    <td align="right">€$sum([(coupons or 0) for sold, count, s, coupons in view.booked if sold.online and not sold.payed])</td>
    <td align="right">€$sum([((s or 0)-(coupons or 0)) for sold, count, s, coupons in view.booked if sold.online and not sold.payed])</td>
    <td>&nbsp;</td>
  </tr>
</table>
<hr>
<h2>Druckvorlagen</h2>
<form action="index.html" method="POST">
$:view.form.render()
</form>
$if pickup:
  <iframe src="sold/$pickup/pickup.html" width=1 height=1 style="display:none;"></iframe>
